/*
 * Team Theta
 * CTC Office
 * CTC Class
 * Yuxin Liu
 */
package edu.pitt.coe1186.theta.ctc;

import edu.pitt.coe1186.theta.util.Global;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBoxBuilder;
import javafx.scene.paint.Color;
import javafx.stage.Modality;
import javafx.stage.Stage;


public class Dialog extends Application  {
	String dialog;
	Scene scene;

	@Override 
    public void start(Stage primaryStage) {
        final Stage stage = primaryStage;

        final Button btnOK = new Button("OK");
        final Button btnCancel = new Button("Cancel");
        final Label label1 = new Label("Set speed limit:"); 
        final TextField textField = new TextField ();
        final Global g = Global.getInstance();

        if(g.getDialog()==null){
        	g.setDialog(new String(""));
        }
        textField.setText(dialog);
        stage.initModality(Modality.WINDOW_MODAL);
        scene = new Scene(VBoxBuilder.create().
                    children(label1,textField,btnOK,btnCancel).
                    alignment(Pos.CENTER).padding(new Insets(5)).build());

        btnOK.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                String id = textField.getText();
                //debug.setText("Set Speedlimit to"+id);
                stage.close();
            }
        });

        btnCancel.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {

                stage.close();
            }
        });
        
        stage.setScene(scene);
        stage.show();


    }


    
}
